/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app2.entidades;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diana Vasquez
 */
@Entity
@Table(name = "solicita")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Solicita.findAll", query = "SELECT s FROM Solicita s"),
    @NamedQuery(name = "Solicita.findByIdFuncionario", query = "SELECT s FROM Solicita s WHERE s.solicitaPK.idFuncionario = :idFuncionario"),
    @NamedQuery(name = "Solicita.findByIdRecurso", query = "SELECT s FROM Solicita s WHERE s.solicitaPK.idRecurso = :idRecurso"),
    @NamedQuery(name = "Solicita.findByFechaPrestamo", query = "SELECT s FROM Solicita s WHERE s.solicitaPK.fechaPrestamo = :fechaPrestamo"),
    @NamedQuery(name = "Solicita.findByFechaDevolucion", query = "SELECT s FROM Solicita s WHERE s.fechaDevolucion = :fechaDevolucion")})
public class Solicita implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SolicitaPK solicitaPK;
    @Column(name = "fecha_devolucion")
    @Temporal(TemporalType.DATE)
    private Date fechaDevolucion;
    @JoinColumn(name = "id_funcionario", referencedColumnName = "id_funcionario", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Funcionario funcionario;
    @JoinColumn(name = "id_recurso", referencedColumnName = "id_recurso", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Recurso recurso;

    public Solicita() {
    }

    public Solicita(SolicitaPK solicitaPK) {
        this.solicitaPK = solicitaPK;
    }

    public Solicita(BigInteger idFuncionario, BigInteger idRecurso, Date fechaPrestamo) {
        this.solicitaPK = new SolicitaPK(idFuncionario, idRecurso, fechaPrestamo);
    }

    public SolicitaPK getSolicitaPK() {
        return solicitaPK;
    }

    public void setSolicitaPK(SolicitaPK solicitaPK) {
        this.solicitaPK = solicitaPK;
    }

    public Date getFechaDevolucion() {
        return fechaDevolucion;
    }

    public void setFechaDevolucion(Date fechaDevolucion) {
        this.fechaDevolucion = fechaDevolucion;
    }

    public Funcionario getFuncionario() {
        return funcionario;
    }

    public void setFuncionario(Funcionario funcionario) {
        this.funcionario = funcionario;
    }

    public Recurso getRecurso() {
        return recurso;
    }

    public void setRecurso(Recurso recurso) {
        this.recurso = recurso;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (solicitaPK != null ? solicitaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Solicita)) {
            return false;
        }
        Solicita other = (Solicita) object;
        if ((this.solicitaPK == null && other.solicitaPK != null) || (this.solicitaPK != null && !this.solicitaPK.equals(other.solicitaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.app2.entidades.Solicita[ solicitaPK=" + solicitaPK + " ]";
    }
    
}
